<script>
	export default {
		onLaunch: function() {
			// #ifdef MP-WEIXIN
			uni.login({
				provider: 'weixin',
				success: res => {
					// 存储code
					this.$utils.setStorage('code', res.code)
					// 通过code登录
					this.$apis.login({
						code: res.code
					}).then((data) => {
						// 输出日志
						this.$utils.setStorage('token', data.token)
						// uni.setStorageSync("token", data.token)
						let tokens = uni.getStorageSync("token")
						console.log('登录成功==userInfo:', tokens)
						this.$apis.getUserInfo({}).then((element) => {
							// 输出日志
							this.$utils.showLog('获取用户信息', element)
							let userInfos = {
								// 用户头像
								avatar: element.avatar,
								// 用户昵称
								nickname: element.nickname,
								// 用户权益
								rights: element.rights,
							}
							this.$utils.setStorage('userInfo', userInfos)
						}).catch((e) => {
							// this.$utils.showToast('登录过期请稍后尝试！', 1000)
						})
					}).catch((e) => {
						// this.$utils.showToast('登录过期请稍后尝试！', 1000)
					})
				},
				fail: () => {
					// this.$utils.showToast('登录过期请稍后尝试！', 1000)
				},
				complete: () => {}
			});
			// #endif

		},
		onShow: function() {
			console.log('App Show')
			let tokens = uni.getStorageSync("token")
			console.log('登录成功==userInfo:', tokens)
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import "@/uni_modules/uview-ui/index.scss";
	/*每个页面公共css */
	@import '@/uni_modules/uv-ui-tools/index.scss';
 @font-face {
    font-family: 'MyLocalFont';
    src: url('@/static/customicons.ttf') format('truetype');
  }
  html,body{
	  font-family: 'MyLocalFont'!important;
  }
	page {
		  font-family: 'MyLocalFont'!important;
		width: 100%;
		height: 100vh;
		margin: 0 auto!important;
		padding: 0 !important;
		background-image: url('https://1257557568.vod-qcloud.com/d34b21d5vodcq1257557568/7b1391ad1397757896686948962/ERawiiRPGZkA.png') !important;
		background-repeat: no-repeat!important;
		background-size: cover!important;
	}

	::v-deep .content .zp-custom-refresher-container {
		// opacity: 0 !important;
	}

	::v-deep .nav-box .uniui-left {
		font-size: 50rpx !important;
	}

	::v-deep .cell--button_primary {
		background-color: red !important;
		width: 100% !important;
		height: 100% !important;
		height: 78rpx !important;
		text-align: center;
		// opacity: 0!important;
		line-height: 78rpx !important;
		text-align: center !important;
		border: 0 !important;
		color: rgba(0, 0, 0, 1) !important;
		background: rgba(0, 0, 0, 0) !important;
	}

	// 单行
	.ellipsis {
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	// header-nav 底部边框色重写
	.uni-nav-bar-text {
		font-size: 32rpx !important;
		font-weight: 500 !important;
	}

	::v-deep .head-boxs .uni-swiper-dots-horizontal {
		bottom: 40rpx !important;
	}

	.course,
	.content .uni-navbar--border {
		border: 0 !important;
	}

	.video-page .uni-navbar--border {
		border: 0 !important;
	}

	// 轮播重写样式

	.head-box .uni-swiper-slides {
		width: 694rpx !important;
		height: 264rpx !important;
	}

	// 重写row样式
	::v-deep .uv-row {
		flex-wrap: wrap !important;
	}

	::v-deep .uv-col {
		text-align: center !important;
	}

	// .head-box .uni-swiper-dots-horizontal{
	// 	bottom: 0!important;
	// }


	// .head-box .uni-swiper-dot {
	// 	width: 52rpx !important;
	// 	height: 10rpx !important;
	// 	border-radius: 6rpx !important;
	// 	background: rgba(0, 0, 0, 1) !important;
	// }

	// .head-box .uni-swiper-dot-active {
	// 	background: rgba(191, 191, 191, 1) !important;
	// 	width: 20rpx !important;
	// 	height: 10rpx !important;
	// 	border-radius: 6rpx !important;
	// }
</style>